package net.qiqb.ddd.user.infrastructure;

import lombok.extern.slf4j.Slf4j;
import net.qiqb.core.domain.annotation.AttachedAggregatePersistence;
import net.qiqb.core.domain.annotation.AttachedAggregatePersistentObj;
import net.qiqb.ddd.user.domain.ExtraAgeUser;
import net.qiqb.ddd.user.domain.ExtraAvatarUser;
import net.qiqb.ddd.user.domain.UserAggregateRoot;

@Slf4j
public class ExtraAvatarUserPersistence implements AttachedAggregatePersistence<UserAggregateRoot, ExtraAvatarUser> {

    @Override
    public void persistAggregate(AttachedAggregatePersistentObj<UserAggregateRoot, ExtraAvatarUser> newObj, AttachedAggregatePersistentObj<UserAggregateRoot, ExtraAvatarUser> oldObj) {
        final UserAggregateRoot userEntity = newObj.getAggregateRoot();
        final ExtraAgeUser UserInfo = userEntity.getAttachedObject(ExtraAgeUser.class);
        log.info("聚合领域：额外头像用户持久化[{}]", newObj);
    }
}
